package com.tjcu.action;

import com.opensymphony.xwork2.ActionSupport;
import com.tjcu.entity.Mark;
import com.tjcu.service.MarkService;
import com.tjcu.service.impl.MarkServiceImpl;

import java.util.Date;
import java.util.List;

/**
 * @author 王恒杰
 * @version 1.0
 * @date 2021/11/1 15:28
 * @email 1078993387@qq.com
 * @Address 天津
 * @Description:
 */
public class MarkAction extends ActionSupport {
    private Mark mark;
    private  List<Mark> marks;

    public String addMark(){
        MarkService markService = new MarkServiceImpl();
        mark.setMid(null);
        mark.setMtime(new Date());
        System.out.println(mark);
        markService.insertMark(mark);
        return SUCCESS;
    }

    public String deleteMark(){
        MarkService markService = new MarkServiceImpl();
        markService.deleteMark(mark.getMid());
        return SUCCESS;
    }

    public String  selectMark(){
        MarkService markService = new MarkServiceImpl();
        marks = markService.selectMark();
        for (Mark mark : marks) {
            System.out.println(mark);
        }
        return SUCCESS;
    }

    public Mark getMark() {
        return mark;
    }

    public void setMark(Mark mark) {
        this.mark = mark;
    }

    public List<Mark> getMarks() {
        return marks;
    }

    public void setMarks(List<Mark> marks) {
        this.marks = marks;
    }
}
